#include "document.h"

using namespace std;

Document::Document() : mRoot(NULL), mSpecNodes(), mDefaultNamespace(NULL), mNsFile(string("")) {
}

Document::~Document() {
	delete mDefaultNamespace;
	delete mRoot;
	
	for (list<SpecNode*>::iterator iter=(mSpecNodes.begin());
	     iter!=(mSpecNodes.end());
	     iter++) {
	
		delete (*iter);	
	}
}

void Document::addSpecNode(SpecNode* specNode) {
	mSpecNodes.push_back(specNode);
}

void Document::setRoot(XmlElement* element) {
	mRoot = element;
}

void Document::setDefaultNamespace(Namespace* ns) {
	mDefaultNamespace = ns;
}

void Document::setNsFile(char* file) {
	mNsFile = string(file);
}
	
Namespace* Document::getDefaultNamespace() {
	return mDefaultNamespace;
}

XmlElement* Document::getRoot() {
	return mRoot;
}

std::string Document::getNsFile() {
	return mNsFile;
}

void Document::print (ostream& out) {
	
	for (list<SpecNode*>::iterator iter=(mSpecNodes.begin());
	     iter!=(mSpecNodes.end());
	     iter++) {
	
		(*iter)->print(out);	
	}
	
	mRoot->print(out);
}
